<template>
    <portlet name="全部产品列表">
        <div class="search_content">
            <i-table :content="self" :columns="columns1" :data="data2"></i-table>
        </div>
        <div class="search_footer">
            <span><Page @on-change='changePage' :total='pageInfor.records' :page-size='pageInfor.rows' :current='pageInfor.page' show-elevator show-sizer></Page></span>
        </div>
    </portlet>
</template>
<script>
    import Portlet from '../../components/portlet.vue';
    import getUrl from '../use/useRouter.js';
    export default {
        components:{ Portlet },
        data () {
            return {
                self:this,
                pageInfor:{
                    page:1,
                    rows:10,
                    records:1,
                },
                columns1: [
                    {
                        type: 'index',
                        width: 60,
                        align: 'center'
                    },
                    {
                        title: '产品名称',
                        key: 'product_name',
                        width:180,
                        align: 'center'
                    },
                    {
                        title: '产品编码',
                        key: 'product_code',
                        align: 'center'
                    },
                    {
                        title: '详情',
                        key: 'product_content',
                        align: 'center'
                    },
                    {
                        title: '接口文档',
                        key: 'document_url',
                        width:100,
                        align: 'center',
                        render (row, column, index) {
                            return `<a href='${row.document_url}'>下载</a>`;
                        }
                    },
                    {
                        title: 'DEMO',
                        key: 'javademo_url',
                        width:60,
                        align: 'center',
                        render (row, column, index) {
                            return `<a href='${row.javademo_url}'>下载</a>`;
                        }
                    },
                    {
                        title: '功能',
                        key: 'sendUrl',
                        width:100,
                        align: 'center',
                        render (row, column, index) {
                            return `<a @click='goToUse(${index})'>在线应用</a>`;
                        }
                    },
                ],
                data1: [
                    
                ]
            }
        },
        computed:{
            data2(){
                return this.data1.map(function(data){
                    return getUrl(data);
                })
            }
        },
        methods: {
            changePage(a){
                this.pageInfor.page=a;
                this.getData();
            },
            changeStartDate(a){
                this.day.startDateD=a.toString();
            },
            changeEndDate(a){
                this.day.endDateD=a.toString();
            },
            searchData(){
                this.getData();
            },
            goToUse(row){
                this.myRouter.go({ path:this.data2[row].sendUrl});
            },
            getData(){
                this.$http.jsonp(this.path+'product/productServlet/productDownList',{
                    params:{page:this.pageInfor.page,
                            rows:this.pageInfor.rows,},
                    jsonp:'callback'
                }).then(
                    (datas)=>{
                        if(datas.body.code=='001'){
                            this.pageInfor.page=parseInt(datas.body.result.page);
                            this.pageInfor.records=datas.body.result.records;
                            this.data1=datas.body.result.rows;
                        }else if(datas.body.code=='002'){
                            this.$Message.success('提交信息出错p!');
                        }else if(datas.body.code=='997'||datas.body.code=='998'){
                            this.store.state.user.companyId=null;
                            this.store.state.user.companyName=null;
                            this.store.state.allInfor=null;
                            this.$Message.error('登陆超时或未登陆,请登陆!');
                            this.myRouter.go({path:'/login'});
                        }
                    },
                    (error)=>{
                        console.log(error)
                        this.$Message.success('网络问题!');
                    }   
                );
            }
        },
        ready(){
            this.$nextTick(()=>{
                this.getData();
         })
        }
    }
</script>
<style scoped lang="less" rel="stylesheet/scss">
    @import '../../styles/query.scss';
</style>